package com.woniuxy.microgoodsserver.auctionmag.mapper;

import com.woniuxy.microgoodsserver.bean.GoodsBrandBean;
import com.woniuxy.microgoodsserver.bean.ImageXcBean;
import com.woniuxy.microgoodsserver.bean.PageRequest;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface GoodsBrandMapper {

    //商品品牌通过id查询
    @Select("select id,brand_numble as brandNumble,brand_name as brandName from t_goods_brand_info where id = #{id} and del_status=0")
    GoodsBrandBean brandFindAllById(@Param("id")int id);

    //商品品牌分页查询
    List<GoodsBrandBean> brandFindAll(@Param("p") PageRequest request, @Param("b")GoodsBrandBean goodsBrandBean);



    //品牌增加
    @Options(useGeneratedKeys = true,keyProperty = "b.id")
    @Insert("insert into t_goods_brand_info " +
            "(brand_name,brand_numble,del_status)" +
            " values(#{b.brandName},#{b.brandNumble},'0')")
    int SaveBrand(@Param("b") GoodsBrandBean goodsBrandBean);


    //品牌修改
    @Update("<script>" +
            "update t_goods_brand_info" +
            "<set>" +
            "<if test='b.brandName != null'>" +
            " brand_name = #{b.brandName}," +
            "</if>" +
            "<if test='b.brandNumble != null'>" +
            " brand_numble = #{b.brandNumble}," +
            "</if>" +
            "</set>" +
            "where id = #{b.id}" +
            "</script>")
    int updateGoodBrandBean(@Param("b") GoodsBrandBean goodsBrandBean);

    //品牌删除
    @Update("<script>" +
            "update t_goods_brand_info" +
            "<set>" +
            " del_status = '1'" +
            "</set>" +
            "where id = #{b.id}" +
            "</script>")
    int delGoodBrandBean(@Param("b") GoodsBrandBean goodsBrandBean);
}
